package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.result.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T12;
import com.ruoyi.service.IT12Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信息反馈Controller
 *
 * @author ruoyi
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/T12")
public class T12Controller extends BaseController
{
    @Autowired
    private IT12Service t12Service;

    /**
     * 查询信息反馈列表
     */

    @GetMapping("/list")
    public TableDataInfo list(T12 t12)
    {
        startPage();
        List<T12> list = t12Service.selectT12List(t12);
        return getDataTable(list);
    }

    /**
     * 导出信息反馈列表
     */

    @Log(title = "信息反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, T12 t12)
    {
        List<T12> list = t12Service.selectT12List(t12);
        ExcelUtil<T12> util = new ExcelUtil<T12>(T12.class);
        util.exportExcel(response, list, "信息反馈数据");
    }

    /**
     * 获取信息反馈详细信息
     */

    @GetMapping(value = "/{F1201}")
    public AjaxResult getInfo(@PathVariable("F1201") Long F1201)
    {
        return success(t12Service.selectT12ByF1201(F1201));
    }

    /**
     * 新增信息反馈
     */

    @Log(title = "信息反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody T12 t12, HttpServletRequest request)
    {
        try {
            return t12Service.addT12(t12,request);
        } catch (Exception e) {
            return Result.erro("添加失败："+e.getMessage());
        }
    }

    /**
     * 修改信息反馈
     */

    @Log(title = "信息反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody T12 t12)
    {
        return toAjax(t12Service.updateT12(t12));
    }

    /**
     * 删除信息反馈
     */

    @Log(title = "信息反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{F1201s}")
    public AjaxResult remove(@PathVariable Long[] F1201s)
    {
        return toAjax(t12Service.deleteT12ByF1201s(F1201s));
    }


    @Log(title = "信息反馈", businessType = BusinessType.INSERT)
    @PostMapping("/toProcess")
    public Result toProcess(@RequestBody T12 t12, HttpServletRequest request)
    {
        try {
            return t12Service.toProcess(t12,request);
        } catch (Exception e) {
            return Result.erro("回复失败："+e.getMessage());
        }
    }
    @PostMapping("/testEmail")
    public Result testEmail(HttpServletRequest request)
    {
        try {
            return t12Service.testEmail(request);
        } catch (Exception e) {
            return Result.erro("邮件发送失败："+e.getMessage());
        }
    }
    @GetMapping("/getWxList")
    @Log(title = "信息反馈", businessType = BusinessType.INSERT)
    public Result getWxList(T12 t12,HttpServletRequest request)
    {
        try {
            return t12Service.getWxList(t12,request);
        } catch (Exception e) {
            return Result.erro("获取失败："+e.getMessage());
        }
    }
}
